$def with (jobs_running, jobs_waiting, from_timestamp)

$#
$# This file is part of INGInious. See the LICENSE and the COPYRIGHTS files for
$# more information about the licensing of this file.
$#

$var title: $:_("Job queue")

$# Start content
$def NavbarF():
    <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
            <li class="breadcrumb-item active"><a href="#"><i class="fa fa-dashboard"></i> $:_("Job queue")
                <span class="sr-only">$:_("(current)")</span></a>
            </li>
        </ol>
    </nav>
$var Navbar: $:NavbarF()

<h2>$:_("Job queue")</h2>
<p>$:_("This page shows a <strong>snapshot</strong> of the job queue.")</p>

<h3>$:_("Running jobs")</h3>
$if jobs_running is not None and len(jobs_running) > 0:
    <table class="table table-striped">
        <tr>
            <th>$:_("Type")</th>
            <th>$:_("Local client")</th>
            <th>$:_("Agent name")</th>
            <th>$:_("Name")</th>
            <th>$:_("Launcher name")</th>
            <th>$:_("Started at")</th>
            <th>$:_("Timeout at")</th>
        </tr>
        $for (job_id, is_current_client_job, agent_name, info, launcher, started_at, max_time) in jobs_running:
            <tr>
                <td data-toggle="tooltip" data-placement="right" title="$job_id">Task</td>
                <td>
                    $if is_current_client_job:
                        $:_("Yes")
                    $else:
                        $:_("No")
                </td>
                <td>$agent_name</td>
                <td>$info</td>
                <td>$launcher</td>
                <td>$from_timestamp(started_at).strftime("%d/%m/%Y %H:%M:%S")</td>
                <td>
                    $if max_time >= 0:
                        $from_timestamp(started_at+max_time).strftime("%d/%m/%Y %H:%M:%S")
                    $else:
                        $:_("No timeout set")
                </td>
            </tr>
    </table>
$else:
    <p>$:_("There are no jobs running")</p>

<h3>$:_("Jobs in queue")</h3>
$if jobs_waiting is not None and len(jobs_waiting) > 0:
    <table class="table table-striped">
        <tr>
            <th>$:_("Type")</th>
            <th>$:_("Local")</th>
            <th>$:_("Name")</th>
            <th>$:_("Launcher name")</th>
            <th>$:_("Maximum runtime in seconds")</th>
        </tr>
        $for (job_id, is_current_client_job, info, launcher, max_time) in jobs_waiting:
        <tr>
            <td data-toggle="tooltip" data-placement="right" title="$job_id">Task</td>
            <td>
                $if is_current_client_job:
                    $:_("Yes")
                $else:
                    $:_("No")
            </td>
            <td>$info</td>
            <td>$launcher</td>
            <td>
                $if max_time >= 0:
                    $max_time
                $else:
                    $:_("No timeout set")
            </td>
        </tr>
    </table>
$else:
    <p>$:_("There are no jobs waiting in queue")</p>
